;(function() {
		init_parsley();
	   	$("#form-submit").click(function(){
	   		var flag=$('#validate-form').parsley('validate' );
	   		var card_no=$("#card_no").val();
	   		if(flag){
	   			$.post(
	   				"/admin/WaterPump/pump_reset",
	   				{"card_no":card_no,"type":0},
			   				function(data){
			   				if(!data.flag){
			   					toastr['error'](data.msg,"操作失败！"); 
			   					return false;
			   				}
			   				var pump_type=data['data']['pump_type'];
							var pump_count=data['data']['pump_count'];
							var pump_minute=data['data']['pump_minute'];	
							var result=set_water_pump(pump_type,pump_count,pump_minute);
							console.log(result);
							if(!result){
								console.log("写卡失败");
								return ;
							}
			   				$.post(
			   					"/admin/WaterPump/pump_reset",
			   					{"card_no":card_no,"type":1},
			   					function(datas){
						      		if(datas.flag){
						      			$("#myModal").modal("hide");
						      			toastr['success']("操作成功！", ''); 
						      			$("#myform #btn-advanced-refresh").trigger("click");// 刷新页面
						      		}else{
						      		 	toastr['error'](datas.msg,"操作失败！"); 
						      		}
			   				}
			   			);
	   				}
	   			);
	   		}
	   	})
	   	
})();
